/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import model.*;
import javax.swing.*;
import java.awt.*;

/**
 *
 * @author Benjamin De Clercq, Michiel Vancoillie, Ruben Slabbinck
 */
public class Vak extends JLabel {

    private int x;
    private int y;

    private Pion pion;
    private boolean bezitPion;

    private Color kleur;

    public Vak(int x, int y, Color kleur) {
        super();

        this.x = x;
        this.y = y;
        this.kleur = kleur;

        pion = null;
        bezitPion = false;

        setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        setOpaque(true);
        setBackground(kleur);
        setSize(50, 50);
    }

    public int getXValue() {
        return x;
    }

    public int getYValue() {
        return y;
    }

    public Boolean bezitPion() {
        return bezitPion;
    }

    public void setPion(Pion p) {
        bezitPion = true;
        pion = p;
    }

    public void removePion() {
        bezitPion = false;
        pion = null;
    }

    public Pion getPion() {
        return pion;
    }

    public void selecteer() {
        setBackground(kleur.brighter());
    }

    public void deselecteer() {
        setBackground(kleur);
    }

    public Boolean zetMogelijk() {
        if (kleur.equals(Bord.KLEUR_MOERAS)){
            return false;
        } else {
            return true;
        }
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        Graphics2D g2=(Graphics2D)g;
        if (bezitPion){
            ImageIcon afbeelding = pion.getImageIcon();
            afbeelding.paintIcon(this, g2, (this.getWidth() - afbeelding.getIconWidth()) / 2, (this.getHeight() - afbeelding.getIconHeight()) / 2);
        }
    }

}

